package com.zc.initConstructor;

import com.zc.service.JedisClient;
import com.zc.utils.redisThread.ThreadRedisRead;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

@Component
public class ObserTwo {
    @Resource
    private ThreadRedisRead redis;
    @Resource
    private JedisClient jedis;
    //spring解析文本资源(xml,property等等),利用@value进行类似map的读取方式
    @Value("${nihao}")
    private String HELLO;
    //方法二:spring注解实现在服务器启动既将数据初始化
    @PostConstruct
    public void init() {
        System.out.println(HELLO);
        Thread aa =new Thread(redis);
        aa.start();
//        jedis.publish("redisMessage","zz");
//        jedis.subscribe("redisMessage");
    }
}
